package com.wise.site.protocol.result;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.wise.site.protocol.base.SoapItem;
import com.wise.site.protocol.base.SoapResult;

/**
 * 列表item
 * @author Administrator
 *
 */
public class BussnissItem  extends SoapItem{
	public int id;
	/**
	 * 列表图连接
	 */
	public String[] iconURL;
	/**
	 * 标题
	 */
	public String title;
	/**
	 * 价格
	 */
	public String price;
	/**
	 * 评论数
	 */
	public int commtNum;
	
	/**
	 * 收藏数
	 */
	public int favoraterNum;
	
	public int userId;
	
	public String phone;
	
	public String description; 
	
	public String company;
	
	public String time;
	
	public String souce;
	
	/**
	 * 联系人
	 */
	public String contactor;
	
	public int shopId;
	
	public BussnissItem() {
	}
	
	public BussnissItem(JSONObject node) {
		super(node);
	}
	
	public void parse(JSONObject node) throws JSONException
    {
		id = node.getInt("id");
		phone = node.getString("phone");
		description = node.getString("description");
		
		if(!node.isNull("name")){
			title = node.getString("name");
		} 
		
		if(!node.isNull("title")){
			title = node.getString("title");
		} 
		
		if(!node.isNull("price")){
			price = node.getString("price");
		}
		
		if(!node.isNull("time")){
			time = node.getString("time");
		}
		
		if(!node.isNull("source")){
			souce = node.getString("source");
		}
		
		if(!node.isNull("company")){
			company = node.getString("company");
		}
		
		if(!node.isNull("imageUrls")){
			String[] temp = node.getString("imageUrls").split(",");
			ArrayList<String> tempBuff = new ArrayList<String>();
			for(String url : temp){
				if(url == null || url.length() < 5){
					continue;
				}
				tempBuff.add(url);
			}
			iconURL = new String[tempBuff.size()];
			tempBuff.toArray(iconURL);
		}
		
		if(!node.isNull("recommended")){
			commtNum = node.getInt("recommended");
		}
		
		if(!node.isNull("countOfFavorater")){
			favoraterNum = node.getInt("countOfFavorater");
		}
		
		if(!node.isNull("contactor")){
			contactor = node.getString("contactor");
		}
		
		if(!node.isNull("shopid")){
			shopId = node.getInt("shopid");
		}
		
		if(!node.isNull("userId")){
			userId = node.getInt("userId");
		}
    }

	
	
	
}
